<!-- 项目进度 -->
<template>
  <el-card :header="title">
    <ele-pro-table :height="410"
                   row-key="id"
                   :columns="columns"
                   :datasource="datasource"
                   highlight-current-row
                   :pagination="false"
                   :toolbar="false"
                   :bottom-line="false"
                   size="large"
                   :needPage="false"
                   class="project-table">
      <!-- 订单信息 -->
      <template v-slot:orderingInformation="{ row }">
        <div class="realNameStyle flex-start">
          <img class="avaterName"
               :src="row.rotationChart"
               alt="" />
          <div class="flex-columns">
            <div>{{ row.tradeName }}</div>
            <div class="price">￥{{ row.disbursements }}</div>
            <div class="technicianName">订单号:{{ row.orderNumber }}</div>
          </div>
        </div>
      </template>

      <!-- 其他信息 -->
      <template v-slot:otherInformation="{ row }">
        <div class="site"> 站点域名:{{ row.siteDomainName }} </div>
        <div class="site"> 站点名称:{{ row.siteName }} </div>
        <div class="creatData">
          创建时间:{{ formattedDate(row.createDate) }}
        </div>
      </template>
    </ele-pro-table>
  </el-card>
</template>

<script>
import { getLatestOrder } from '@/api/mainPlatform/index';
import moment from 'moment';
export default {
  name: 'reflectList',
  components: {},
  data () {
    return {
      //  技能评分
      colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
      value: 4,
      // 表格列配置
      columns: [
        {
          prop: 'orderingInformation',
          label: '订单信息',
          sortable: 'custom',

          showOverflowTooltip: true,
          minWidth: 160,
          slot: 'orderingInformation'
        },
        {
          prop: 'classificationName',
          label: '类目',
          sortable: 'custom',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'classificationName'
        },
        {
          prop: 'servicePrice',
          label: '产品价格',
          sortable: 'custom',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'servicePrice'
        },
        {
          prop: 'orderTotal',
          label: '数量',
          sortable: 'custom',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'orderTotal'
        },
        {
          prop: 'otherInformation',
          label: '其他信息',
          sortable: 'custom',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 150,
          slot: 'otherInformation'
        }
      ],
      current: null,
      // 表格选中数据
      selection: [],
      drawerReflectBoolen: false
    };
  },
  computed: {
    // 是否开启响应式布局
    styleResponsive () {
      return this.$store.state.theme.styleResponsive;
    },
    // 时间格式化
    formattedDate () {
      return (params) => {
        const currentDate = moment(params);
        const formattedDate = currentDate.format('YYYY-MM-DD HH:mm');
        return formattedDate;
      };
    },
    // 服务状态
    type () {
      return function (type) {
        // console.log(applyType)
        if (type == '1') {
          return {
            status: '签到',
            type: 'success'
          };
        } else if (type == '2') {
          return {
            status: '邀请',
            type: ''
          };
        } else if (type == '3') {
          return {
            status: '下单',
            type: 'danger'
          };
        } else {
          return {
            status: '后台操作',
            type: 'warning'
          };
        }
      };
    },
    // 实名认证
    integralType () {
      return function (integralType) {
        if (integralType == '1') {
          return {
            status: '收入',
            type: 'danger'
          };
        } else {
          return {
            status: '支出',
            type: 'success'
          };
        }
      };
    }
  },
  methods: {
    // 点击查看详情弹出详情抽屉
    viewDetail (row) {
      console.log(row);

      if (row) {
        this.current = row;
        // 用户余额管理
        this.drawerReflectBoolen = !this.drawerReflectBoolen;
      }
    },

    /* 表格数据源 */
    datasource ({ page, limit, where, order }) {
      return getLatestOrder({ page, limit });
    },
    /* 刷新表格 */
    reload (where) {
      this.$refs.table.reload({ page: 1, where: where, types: 1 });
    },

    /* 删除 */
    remove (row) {
      const loading = this.$loading({ lock: true });
      pointsDetailsDelete(row.id)
        .then((msg) => {
          loading.close();
          this.$message.success(msg);
          this.reload();
        })
        .catch((e) => {
          loading.close();
          this.$message.error(e.message);
        });
    },
    /* 批量删除 */
    removeBatch () {
      if (!this.selection.length) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      console.log(this.selection);
      this.$confirm('确定要删除选中的信息吗?', '提示', {
        type: 'warning'
      })
        .then(() => {
          const loading = this.$loading({ lock: true });
          console.log(this.selection.map((d) => d.id));
          pointsDetailsBatch(this.selection.map((d) => d.id))
            .then((msg) => {
              loading.close();
              this.$message.success(msg);
              this.reload();
            })
            .catch((e) => {
              loading.close();
              this.$message.error(e.message);
            });
        })
        .catch(() => { });
    }
  }
};
</script>
<style lang="less" scoped>
.project-table :deep(.el-progress__text) {
  font-size: 12px !important;
}
.realNameStyle {
  .avaterName {
    width: 74px;
    height: 74px;
    vertical-align: middle;
    margin-right: 15px;
    border-radius: 10px;
  }
  .price {
    color: #f00;
    font-family: Inter;
    font-size: 16px;
  }
  .technicianName {
    color: #999;
    font-family: Inter;
    font-size: 12px;
  }
}
.site {
  color: #666;
  font-family: Inter;
  font-size: 14px;
}
.creatData {
  color: #999;
  font-family: Inter;
  font-size: 14px;
}
</style>
